package com.aramco.fion.model.presentation
{
	import com.aramco.fion.model.FlexConstants;
	import com.aramco.fion.util.SelectionUtil;
	import com.aramco.fion.view.SelectionReport;
	import com.aramco.fion.view.selection.Popup.BASE_POPUP_SELECTION;
	import com.aramco.fion.view.selection.Popup.SWIZ_POPUP_PAGE_F4_SELEC_POPUP;
	import com.aramco.fion.vo.VariableInfo;
	import com.aramco.fion.vo.selection.SelectionVo;
	
	import mx.collections.ArrayCollection;

	[Bindable]
	public class SelectionReportPresentataionModel
	{
		public var view:SelectionReport;
		
		
		private var _selectionsVo:ArrayCollection;
		
		public function SelectionReportPresentataionModel()
		{
		}
		
		private var _selectionMeta:ArrayCollection;

		
		public function get selectionsVo():ArrayCollection
		{
			return _selectionsVo;
		}

		public function set selectionsVo(value:ArrayCollection):void
		{
			_selectionsVo = value;
		}

		[Inject("queryModel.querySelectionsMeta", bind="true")]
		public function get selectionMeta():ArrayCollection
		{
			return _selectionMeta;
		}

		public function set selectionMeta(value:ArrayCollection):void
		{
			_selectionMeta = value;
			addSelectionComponentsToView(value);
		}
		
		[ViewAdded]
		public function userListViewAdded( view : SelectionReport ) : void
		{
			this.view = view;
			trace('SelectionReport: added');
		}
		
		private function addSelectionComponentsToView(value:ArrayCollection):void
		{
			if(view != null)
			{
				for(var i:int = 0; i < value.length; i++)
				{
					//var comp:SWIZ_POPUP_PAGE_F4_SELEC_POPUP = new SWIZ_POPUP_PAGE_F4_SELEC_POPUP();
					//var obj2:VariableInfo = new VariableInfo();
					var comp:BASE_POPUP_SELECTION= new BASE_POPUP_SELECTION();
					
					/*var obj:Object = new Object();
					obj.ZVAR_DESCRIPTION = value[i]['label'];
					obj.ZVARNAME = value[i]['techname'];
					obj.CLASSNAME = 'AD_POPUP_F4_PAGE_SELEC';*/
					var meta:VariableInfo = value[i];
					meta.componentName = "FION_POPUP_F4_PAGE_SELEC";
					comp.currentSelection = SelectionUtil.formatVariablesScreenMetadata(value[i]) as SelectionVo;
					comp.metaData = value[i];
					view.myGroup.addElement(comp);
				}
			}
		}

	}
}